<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>项目添加页面</title>
    <link rel="stylesheet" type="text/css" href="../../static/admin/layui2/css/layui.css"/>
</head>
<body class="layui-layout-admin" >
<div class="layui-anim layui-anim-scale">
    <form class="layui-form layui-form-pane" name="form1" id="form1" style="margin-top: 20px;">
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">项目</label>
            <div class="layui-input-inline">
                <select name="xiangmubianma" id="xiangmubianma" lay-filter="xfilter" lay-verify="required">
                    <option>--请选择--</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">楼栋</label>
            <div class="layui-input-inline">
                <select name="loudongbianma" id="loudongbianma" lay-verify="required">
                    <option>--请选择--</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">套房名称</label>
            <div class="layui-input-inline">
                <input type="text" name="taofangmingcheng" id="taofangmingcheng" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">权利人名称</label>
            <div class="layui-input-inline">
                <input type="text" name="quanlirenmingcheng" id="quanlirenmingcheng" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">启用状态</label>
            <div class="layui-input-block">
                <input type="radio" name="qiyongzhuangtai" id="open" value="1" title="启用">
                <input type="radio" name="qiyongzhuangtai" id="close" value="0" title="禁 用">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">房产物业地址</label>
            <div class="layui-input-inline">
                <input type="text" name="fangchanwuyedizhi" id="fangchanwuyedizhi" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">房产物业旧地址</label>
            <div class="layui-input-inline">
                <input type="text" name="fangchanwuyejiudizhi" id="fangchanwuyejiudizhi" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">楼栋使用面积</label>
            <div class="layui-input-inline">
                <input type="text" name="loudongshiyongmianji" id="loudongshiyongmianji" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">楼 层</label>
            <div class="layui-input-inline">
                <input type="text" name="louceng" id="louceng" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">房产证编号</label>
            <div class="layui-input-inline">
                <input type="text" name="fangchanzhengbianhao" id="fangchanzhengbianhao" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">固定资产号</label>
            <div class="layui-input-inline">
                <input type="text" name="gudingzichankahao" id="gudingzichankahao" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">使用面积</label>
            <div class="layui-input-inline">
                <input type="text" name="shiyongmianji" id="shiyongmianji" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">公摊面积</label>
            <div class="layui-input-inline">
                <input type="text" name="gongtanmianji" id="gongtanmianji" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">建筑面积</label>
            <div class="layui-input-inline">
                <input type="text" name="jianzhumianji" id="jianzhumianji" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">实际使用面积</label>
            <div class="layui-input-inline">
                <input type="text" name="shijishiyongmianji" id="shijishiyongmianji" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">户型</label>
            <div class="layui-input-block">
                <input type="radio" name="huxing"  value="A" title="A型">
                <input type="radio" name="huxing"  value="B" title="B型">
                <input type="radio" name="huxing"  value="C" title="C型">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">房间数</label>
            <div class="layui-input-inline">
                <input type="text" name="fangjianshu" id="fangjianshu" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 130px;">备注</label>
            <div class="layui-input-inline" style="width: 400px">
                <textarea placeholder="请输入内容" class="layui-textarea" name="beizhu" id="beizhu"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">添 加</button>
            </div>
        </div>
    </form>
</div>
</div>
<script src="../../static/admin/layui2/layui.js" type="text/javascript" charset="utf-8"></script>
<script>
    layui.use(['element','form','jquery','layer','laydate'], function() {
        var element = layui.element
        var form = layui.form
        layer = layui.layer
        $ = layui.jquery;
        form.render('select');
        $.ajax({
            type: "GET",
            url: "/yuangong/selectAllxiangmu",
            dataType: "json",
            success: function (res) {
                var ops = '<option value="">--请选择--</option>';
                for (var xiangmu of res.data) {
                    ops += '<option value="' + xiangmu.xiangmubianma + '">' + xiangmu.xiangmumingcheng+ '</option>';
                }
                $('#xiangmubianma').html(ops);
                form.render('select');
            }
        });
        form.on('select(xfilter)',function() {
            var xiangmubianma = $('#xiangmubianma').val();
            $.ajax({
                type: "GET",
                url: "/yuangong/selectAllloudong",
                data: {"xiangmubianma": xiangmubianma},
                dataType: "json",
                success: function (res) {
                    var ops = '<option value="">--请选择--</option>';
                    for (var loudong of res.data) {
                        ops += '<option value="' + loudong.loudongbianma + '">' + loudong.loudong + '</option>';
                    }
                    $('#loudongbianma').html(ops);
                    form.render('select');
                }
            })
        })
        form.on('submit(demo1)',function(data){
            $.ajax({
                type:"POST",
                url:"/taofang/add",
                data:{
                    "xiangmubianma":data.field.xiangmubianma,
                    "loudongbianma": data.field.loudongbianma,
                    "taofangmingcheng": data.field.taofangmingcheng,
                    "quanlirenmingcheng": data.field.quanlirenmingcheng,
                    "qiyongzhuangtai":data.field.qiyongzhuangtai,
                    "fangchanwuyedizhi":data.field.fangchanwuyedizhi,
                    "fangchanwuyejiudizhi":data.field.fangchanwuyejiudizhi,
                    "loudongshiyongmianji":data.field.loudongshiyongmianji,
                    "louceng":data.field.louceng,
                    "fangchanzhengbianhao":data.field.fangchanzhengbianhao,
                    "gudingzichankahao":data.field.gudingzichankahao,
                    "shiyongmianji":data.field.shiyongmianji,
                    "gongtanmianji":data.field.gongtanmianji,
                    "jianzhumianji":data.field.jianzhumianji,
                    "shijishiyongmianji":data.field.shijishiyongmianji,
                    "huxing":data.field.huxing,
                    "fangjianshu":data.field.fangjianshu,
                    "beizhu":data.field.beizhu,
                },
                dataType:"json",
                success:function (res) {
                    if (res.flag) {
                        layer.msg('添加成功！',{icon:6,offset:"auto",time:2000});//提示框,提示2秒自动消失
                    }else  {
                        layer.msg('添加失败！',{icon:5,offset:"auto",time:2000});//提示框
                    }
                    setTimeout(function(){
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);//关闭弹出层
                        parent.location.reload();//重新加载父页面表格
                    }, 2100);
                }
            })
            return false;
        });
    });
</script>
</body>
</html>